#include "comm.hpp"

int main()
{
    // 1.生成共享内存的key值
    int key = getKey();
    printf("key: 0x%x\n", key);

    // 2.创建共享内存
    int shmid = creatSHM(key);
    std::cout << "shmid: " << shmid << std::endl;

    // 3.挂接共享内存
    void *start = attachSHM(shmid);
    std::cout << "start address: " << start << std::endl;

    while(1)
    {
        printf("%s",(char*)start);
        sleep(1);
    }
 
    //4.去关联
    detachSHM(start);

    delSHM(shmid);

    return 0;
}


